extends Node

const player_pre = preload("res://actor/base_actor.tscn")
var players : Dictionary = {}
var current_scene
#判断是否主控端
#if is_multiplayer_authority():
	#update_health.rpc(100)

func _ready() -> void:
	current_scene = get_tree().current_scene

#authority：仅由主控端（如服务器）调用。
#any_peer：允许任何对等端调用。
#call_local：调用时在本地也执行。
#reliable/unreliable：设置数据传输的可靠性。
@rpc("authority", "call_local", "reliable")
func _add_player(id : int) :
	print("连接：",id)
	var player = player_pre.instantiate()
	player.name = str(id)
	players[name] = self
	call_deferred("add_child",player)

@rpc("authority", "call_remote", "reliable")
func _remove_player(id : int) :
	print("断连：",id)
	var player = players.get(str(id))
	if player : player._destory()
	
